home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 60 / IOPROG_60.ISO / soft / c++ / gsl-1.1.1-setup.exe / {app} / src / err / test.c < prev    next >
Encoding:
C/C++ Source or Header  |  2001-08-22  |  2.7 KB  |  117 lines

  1. /* err/test_errnos.c
  2.  * 
  3.  * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman, Brian Gough
  4.  * 
  5.  * This program is free software; you can redistribute it and/or modify
  6.  * it under the terms of the GNU General Public License as published by
  7.  * the Free Software Foundation; either version 2 of the License, or (at
  8.  * your option) any later version.
  9.  * 
  10.  * This program is distributed in the hope that it will be useful, but
  11.  * WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.  * General Public License for more details.
  14.  * 
  15.  * You should have received a copy of the GNU General Public License
  16.  * along with this program; if not, write to the Free Software
  17.  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  */
  19.  
  20. #include <config.h>
  21.  
  22. #include <stdio.h>
  23. #include <stdlib.h>
  24.  
  25. #include <gsl/gsl_errno.h>
  26. #include <gsl/gsl_test.h>
  27.  
  28. #define CHECK(x) errors[n].number = x ; errors[n].name = #x ; n++ ;
  29. #define MAX_ERRS 64
  30.  
  31. int verbose = 0 ;
  32.  
  33. int
  34. main (void)
  35. {
  36.   int i, j, n = 0 ;
  37.  
  38.   struct { 
  39.     int number; 
  40.     const char * name; 
  41.   } errors[MAX_ERRS] ;
  42.  
  43.   CHECK(GSL_SUCCESS);
  44.   CHECK(GSL_FAILURE);
  45.   CHECK(GSL_CONTINUE);
  46.   CHECK(GSL_EDOM);
  47.   CHECK(GSL_ERANGE);
  48.   CHECK(GSL_EFAULT);
  49.   CHECK(GSL_EINVAL);
  50.   CHECK(GSL_EFAILED);
  51.   CHECK(GSL_EFACTOR);
  52.   CHECK(GSL_ESANITY);
  53.   CHECK(GSL_ENOMEM);
  54.   CHECK(GSL_EBADFUNC);
  55.   CHECK(GSL_ERUNAWAY);
  56.   CHECK(GSL_EMAXITER);
  57.   CHECK(GSL_EZERODIV);
  58.   CHECK(GSL_EBADTOL);
  59.   CHECK(GSL_ETOL);
  60.   CHECK(GSL_EUNDRFLW);
  61.   CHECK(GSL_EOVRFLW);
  62.   CHECK(GSL_ELOSS);
  63.   CHECK(GSL_EROUND);
  64.   CHECK(GSL_EBADLEN);
  65.   CHECK(GSL_ENOTSQR);
  66.   CHECK(GSL_ESING);
  67.   CHECK(GSL_EDIVERGE);
  68.   CHECK(GSL_EUNSUP);
  69.   CHECK(GSL_EUNIMPL);
  70.   CHECK(GSL_ECACHE);
  71.   CHECK(GSL_ETABLE);
  72.   CHECK(GSL_ENOPROG);
  73.   CHECK(GSL_ENOPROGJ);
  74.   CHECK(GSL_ETOLF);
  75.   CHECK(GSL_ETOLX);
  76.   CHECK(GSL_ETOLG);
  77.   CHECK(GSL_EOF);
  78.  
  79.   for (i = 0 ; i < n ; i++) 
  80.     {
  81.       if (verbose) printf ("%s = %d\n", errors[i].name, errors[i].number) ;
  82.     }
  83.  
  84.   for (i = 0; i < n; i++)
  85.     {
  86.       int status = 0;
  87.       for (j = 0; j < n; j++)
  88.     {
  89.       if (j != i)
  90.           status |= (errors[i].number == errors[j].number);
  91.     }
  92.  
  93.       gsl_test (status, "%s is distinct from other error values",
  94.         errors[i].name);
  95.     }
  96.  
  97.   for (i = 0; i < n; i++)
  98.     {
  99.       int status = 0;
  100.       int e1 = errors[i].number ;
  101.       for (j = 0; j < n; j++)
  102.     {
  103.       if (j != i)
  104.         {
  105.           int e2 = errors[j].number;
  106.           status |= (gsl_strerror(e1) == gsl_strerror(e2)) ;
  107.         }
  108.     }
  109.       gsl_test (status, "%s has a distinct error message",
  110.         errors[i].name);
  111.     }
  112.  
  113.   
  114.   exit (gsl_test_summary ());
  115. }
  116.  
  117.